<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
   
   <meta name="description" content="string operations">
    
    <meta name="author" content="John S. Urban" >
    <link rel="icon" href="../favicon.png">

    <title>string_to_values &ndash; M_strings</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/pygments.css" rel="stylesheet">
    <link href="../css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/local.css" rel="stylesheet">
    
    <link  href="../tipuesearch/tipuesearch.css" rel="stylesheet">
    
    

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script src="../js/jquery-2.1.3.min.js"></script>
    <script src="../js/svg-pan-zoom.min.js"></script>

  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="../index.html">M_strings </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
        
            <li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
              <a href="#" class="dropdown-toggle"
              data-toggle="dropdown" role="button"
              aria-haspopup="true"
     aria-expanded="false">Contents <span class="caret"></span></a>
        <ul class="dropdown-menu">
          
              
            <li><a href="../lists/files.html">Source Files</a></li>
        
        
        
            <li><a href="../lists/modules.html">Modules</a></li>
        
            
                                
            <li><a href="../lists/procedures.html">Procedures</a></li>
        
               
            <li><a href="../lists/types.html">Derived Types</a></li>
        
        
            </ul>
            </li>


<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>

                             
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>


          </ul>
        
        <form action="../search.html" class="navbar-form navbar-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
        </div>
<!--
        <button type="submit" class="btn btn-default">Submit</button>
-->
        </form>
        
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
    
  
  <div class="row">
    <h1>string_to_values
      <small>Subroutine</small>
    
    </h1>
    
<div class="row">
  <div class="col-lg-12">
<div class="well well-sm">
  <ul class="list-inline" style="margin-bottom:0px;display:inline">
     
     
     
     
    
    
     <li><i class="fa fa-list-ol"></i>
       <a data-toggle="tooltip"
    data-placement="bottom" data-html="true"
    title=" 2.8% of total for procedures.">68 statements</a>
     </li> 
     
     
     
    <li><i class="fa fa-code"></i><a href="../src/M_strings.f90"> Source File</a></li>
     
     
  </ul>
  <ol class="breadcrumb in-well text-right">
  
    
     <li><a href='../sourcefile/m_strings.f90.html'>M_strings.f90</a></li>
    
     <li><a href='../module/m_strings.html'>M_strings</a></li>
    
  
     <li class="active">string_to_values</li>
  </ol>
</div>
</div>
</div>
<script>
  $(function () {
  $('[data-toggle="tooltip"]').tooltip()
  })
</script>

  </div>
  
  <div class="row">
    <div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
    
<div id="sidebar">
  
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-0">Variables</a></h3></div>
  <div id="vars-0" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-delimiters_length">delimiters_length</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-delims_local">delims_local</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-i10~6">i10</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-i20~2">i20</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-i40">i40</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-icol~3">icol</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-iend~7">iend</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-ier~2">ier</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-istart~3">istart</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-lgth~10">lgth</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-rval">rval</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/string_to_values.html#src">string_to_values</a>
  </div>
</div>



</div>

    </div>
    
    <div class="col-md-9" id='text'>
    <h2>
public subroutine string_to_values(line, iread, values, inums, delims, ierr)
    
    
   
</h2>
    
  


    
    <h2 id="name">NAME</h2>
<div class="codehilite"><pre><span></span><code>  string_to_values(3f) - [M_strings:NUMERIC] read a string representing
  numbers into a numeric array
  (LICENSE:PD)
</code></pre></div>

<h2 id="synopsis">SYNOPSIS</h2>
<div class="codehilite"><pre><span></span><code>   subroutine string_to_values(line,iread,values,inums,delims,ierr)

    character(len=*) :: line
    integer          :: iread
    real             :: values(*)
    integer          :: inums
    character(len=*) :: delims
    integer          :: ierr
</code></pre></div>

<h2 id="description">DESCRIPTION</h2>
<div class="codehilite"><pre><span></span><code><span class="nv">This</span> <span class="nv">routine</span> <span class="nv">can</span> <span class="nv">take</span> <span class="nv">a</span> <span class="nv">string</span> <span class="nv">representing</span> <span class="nv">a</span> <span class="nv">series</span> <span class="nv">of</span> <span class="nv">numbers</span> <span class="nv">and</span>
<span class="nv">convert</span> <span class="nv">it</span> <span class="nv">to</span> <span class="nv">a</span> <span class="nv">numeric</span> <span class="nv">array</span> <span class="nv">and</span> <span class="k">return</span> <span class="nv">how</span> <span class="nv">many</span> <span class="nv">numbers</span> <span class="nv">were</span> <span class="nv">found</span>.
</code></pre></div>

<h2 id="options">OPTIONS</h2>
<div class="codehilite"><pre><span></span><code>   LINE     Input string containing numbers
   IREAD    maximum number of values to try to read from input string
</code></pre></div>

<h2 id="results">RESULTS</h2>
<div class="codehilite"><pre><span></span><code>   <span class="nv">VALUES</span>   <span class="nv">real</span> <span class="nv">array</span> <span class="nv">to</span> <span class="nv">be</span> <span class="nv">filled</span> <span class="nv">with</span> <span class="nv">numbers</span>
   <span class="nv">INUMS</span>    <span class="nv">number</span> <span class="nv">of</span> <span class="nv">values</span> <span class="nv">successfully</span> <span class="nv">read</span> <span class="ss">(</span><span class="nv">before</span> <span class="nv">error</span> <span class="nv">occurs</span>
            <span class="k">if</span> <span class="nv">one</span> <span class="nv">does</span><span class="ss">)</span>
   <span class="nv">DELIMS</span>   <span class="nv">delimiter</span> <span class="nv">character</span><span class="ss">(</span><span class="nv">s</span><span class="ss">)</span>, <span class="nv">usually</span> <span class="nv">a</span> <span class="nv">space</span>. <span class="nv">must</span> <span class="nv">not</span> <span class="nv">be</span> <span class="nv">a</span>
            <span class="nv">null</span> <span class="nv">string</span>. <span class="k">If</span> <span class="nv">more</span> <span class="nv">than</span> <span class="nv">one</span> <span class="nv">character</span>, <span class="nv">a</span> <span class="nv">space</span> <span class="nv">must</span>
            <span class="nv">not</span> <span class="nv">be</span> <span class="nv">the</span> <span class="nv">last</span> <span class="nv">character</span> <span class="nv">or</span> <span class="nv">it</span> <span class="nv">will</span> <span class="nv">be</span> <span class="nv">ignored</span>.
   <span class="nv">IERR</span>     <span class="nv">error</span> <span class="nv">flag</span> <span class="ss">(</span><span class="mi">0</span><span class="o">=</span><span class="nv">no</span> <span class="nv">error</span>, <span class="k">else</span> <span class="nv">column</span> <span class="nv">number</span> <span class="nv">string</span> <span class="nv">starts</span>
            <span class="nv">at</span> <span class="nv">that</span> <span class="nv">error</span> <span class="nv">occurred</span> <span class="nv">on</span><span class="ss">)</span>.
</code></pre></div>

<h2 id="example">EXAMPLE</h2>
<div class="codehilite"><pre><span></span><code><span class="nt">Sample</span> <span class="nt">Program</span><span class="o">:</span>

  <span class="nt">program</span> <span class="nt">demo_string_to_values</span>
   <span class="nt">use</span> <span class="nt">M_strings</span><span class="o">,</span> <span class="nt">only</span> <span class="o">:</span> <span class="nt">string_to_values</span>
   <span class="nt">implicit</span> <span class="nt">none</span>
   <span class="nt">character</span><span class="o">(</span><span class="nt">len</span><span class="o">=</span><span class="nt">80</span><span class="o">)</span>  <span class="o">::</span> <span class="nt">s</span><span class="o">=</span><span class="s1">&#39; 10 20e3;3.45 -400.3e-2;1234; 5678 &#39;</span>
   <span class="nt">integer</span><span class="o">,</span><span class="nt">parameter</span>  <span class="o">::</span> <span class="nt">isz</span><span class="o">=</span><span class="nt">10</span>
   <span class="nt">real</span>               <span class="o">::</span> <span class="nt">array</span><span class="o">(</span><span class="nt">isz</span><span class="o">)</span>
   <span class="nt">integer</span>            <span class="o">::</span> <span class="nt">inums</span><span class="o">,</span> <span class="nt">ierr</span><span class="o">,</span> <span class="nt">ii</span>

   <span class="nt">call</span> <span class="nt">string_to_values</span><span class="o">(</span><span class="nt">s</span><span class="o">,</span><span class="nt">10</span><span class="o">,</span><span class="nt">array</span><span class="o">,</span><span class="nt">inums</span><span class="o">,</span><span class="s1">&#39; ;&#39;</span><span class="o">,</span><span class="nt">ierr</span><span class="o">)</span>
   <span class="nt">call</span> <span class="nt">reportit</span><span class="o">()</span>

   <span class="nt">call</span> <span class="nt">string_to_values</span><span class="o">(</span><span class="s1">&#39;10;2.3;3.1416&#39;</span><span class="o">,</span><span class="nt">isz</span><span class="o">,</span><span class="nt">array</span><span class="o">,</span><span class="nt">inums</span><span class="o">,</span><span class="s1">&#39; ;&#39;</span><span class="o">,</span><span class="nt">ierr</span><span class="o">)</span>
   <span class="nt">call</span> <span class="nt">reportit</span><span class="o">()</span>

   <span class="nt">contains</span>
      <span class="nt">subroutine</span> <span class="nt">reportit</span><span class="o">()</span>
         <span class="nt">write</span><span class="o">(*,*)</span><span class="s1">&#39;string_to_values:&#39;</span>
         <span class="nt">write</span><span class="o">(*,*)</span><span class="s1">&#39;input string.............&#39;</span><span class="o">,</span><span class="nt">trim</span><span class="o">(</span><span class="nt">s</span><span class="o">)</span>
         <span class="nt">write</span><span class="o">(*,*)</span><span class="s1">&#39;number of values found...&#39;</span><span class="o">,</span><span class="nt">inums</span>
         <span class="nt">write</span><span class="o">(*,*)</span><span class="s1">&#39;values...................&#39;</span><span class="o">,(</span><span class="nt">array</span><span class="o">(</span><span class="nt">ii</span><span class="o">),</span><span class="nt">ii</span><span class="o">=</span><span class="nt">1</span><span class="o">,</span><span class="nt">inums</span><span class="o">)</span>
      <span class="nt">end</span> <span class="nt">subroutine</span> <span class="nt">reportit</span>
  <span class="nt">end</span> <span class="nt">program</span> <span class="nt">demo_string_to_values</span>

<span class="nt">Expected</span> <span class="nt">output</span>

 <span class="nt">string_to_values</span><span class="o">:</span>
 <span class="nt">input</span> <span class="nt">string</span><span class="o">.............</span> <span class="nt">10</span> <span class="nt">20e3</span><span class="o">;</span><span class="nt">3</span><span class="p">.</span><span class="nc">45</span> <span class="nt">-400</span><span class="p">.</span><span class="nc">3e-2</span><span class="o">;</span><span class="nt">1234</span><span class="o">;</span> <span class="nt">5678</span>
 <span class="nt">number</span> <span class="nt">of</span> <span class="nt">values</span> <span class="nt">found</span><span class="o">...</span>           <span class="nt">6</span>
 <span class="nt">values</span><span class="o">...................</span>   <span class="nt">10</span><span class="p">.</span><span class="nc">0000000</span>  <span class="nt">20000</span><span class="p">.</span><span class="nc">0000</span>  <span class="nt">3</span><span class="p">.</span><span class="nc">45000005</span>
 <span class="nt">-4</span><span class="p">.</span><span class="nc">00299978</span>  <span class="nt">1234</span><span class="p">.</span><span class="nc">00000</span>  <span class="nt">5678</span><span class="p">.</span><span class="nc">00000</span>
 <span class="nt">string_to_values</span><span class="o">:</span>
 <span class="nt">input</span> <span class="nt">string</span><span class="o">.............</span> <span class="nt">10</span> <span class="nt">20e3</span><span class="o">;</span><span class="nt">3</span><span class="p">.</span><span class="nc">45</span> <span class="nt">-400</span><span class="p">.</span><span class="nc">3e-2</span><span class="o">;</span><span class="nt">1234</span><span class="o">;</span> <span class="nt">5678</span>
 <span class="nt">number</span> <span class="nt">of</span> <span class="nt">values</span> <span class="nt">found</span><span class="o">...</span>           <span class="nt">3</span>
 <span class="nt">values</span><span class="o">...................</span>   <span class="nt">10</span><span class="p">.</span><span class="nc">0000000</span>  <span class="nt">2</span><span class="p">.</span><span class="nc">29999995</span>  <span class="nt">3</span><span class="p">.</span><span class="nc">14159989</span>
</code></pre></div>

<h2 id="author">AUTHOR</h2>
<div class="codehilite"><pre><span></span><code>John S. Urban
</code></pre></div>

<h2 id="license">LICENSE</h2>
<div class="codehilite"><pre><span></span><code>Public Domain
</code></pre></div>
    

    <h3>Arguments</h3>
    
      
<table class="table table-striped varlist">
<thead><tr><th>Type</th>
<th>Intent</th><th>Optional</th>
<th>Attributes</th><th></th><th>Name</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-line~10"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>line</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iread"></span>integer,</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>iread</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-values~2"></span>real,</td>
  <td>intent(inout)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>values</strong>(iread)</td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-inums"></span>integer,</td>
  <td>intent(out)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>inums</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-delims"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>delims</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ierr~7"></span>integer,</td>
  <td>intent(out)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>ierr</strong></td><td></td>
  
</tr>

</tbody>
</table>

    
    
    
    
     
    <br>

    <section class="visible-xs visible-sm hidden-md">
      
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-1">Variables</a></h3></div>
  <div id="vars-1" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-delimiters_length">delimiters_length</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-delims_local">delims_local</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-i10~6">i10</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-i20~2">i20</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-i40">i40</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-icol~3">icol</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-iend~7">iend</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-ier~2">ier</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-istart~3">istart</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-lgth~10">lgth</a>
      
      <a class="list-group-item" href="../proc/string_to_values.html#variable-rval">rval</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/string_to_values.html#src">string_to_values</a>
  </div>
</div>



    </section>
    <br class="visible-xs visible-sm hidden-md">

    

    
    <section>    
      <h2>Variables</h2>
    
<table class="table table-striped varlist">
<thead><tr><th>Type</th><th>Visibility</th>

<th>Attributes</th><th></th><th>Name</th><th></th><th>Initial</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-delimiters_length"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>delimiters_length</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-delims_local"></span>character(len=256),</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>delims_local</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i10~6"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i10</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i20~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i20</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i40"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i40</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-icol~3"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>icol</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iend~7"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>iend</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ier~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>ier</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-istart~3"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>istart</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-lgth~10"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>lgth</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-rval"></span>real,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>rval</strong></td><td></td><td></td><td></td>
  
</tr>

</tbody>
</table>

    </section>
    <br>
    
    
    
    
    

    
    
    
    
    


    
    
    
    <section>
    <h2><span class="anchor" id="src"></span>Source Code</h2>
    <div class="highlight"><pre><span></span><span class="k">subroutine </span><span class="n">string_to_values</span><span class="p">(</span><span class="n">line</span><span class="p">,</span><span class="n">iread</span><span class="p">,</span><span class="n">values</span><span class="p">,</span><span class="n">inums</span><span class="p">,</span><span class="n">delims</span><span class="p">,</span><span class="n">ierr</span><span class="p">)</span>
<span class="k">implicit none</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------------</span>
<span class="c">!   1989,1997-12-31,2014 John S. Urban</span>

<span class="c">!   given a line of structure , string , string , string process each</span>
<span class="c">!   string as a numeric value and store into an array.</span>
<span class="c">!   DELIMS contain the legal delimiters. If a space is an allowed delimiter, it must not appear last in DELIMS.</span>
<span class="c">!   There is no direct checking for more values than can fit in VALUES.</span>
<span class="c">!   Quits if encounters any errors in read.</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------------</span>

<span class="c">! ident_56=&quot;@(#)M_strings::string_to_values(3f): reads an array of numbers from a numeric string&quot;</span>

<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>  <span class="kd">::</span> <span class="n">line</span>          <span class="c">! input string</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>           <span class="kd">::</span> <span class="n">iread</span>         <span class="c">! maximum number of values to try to read into values</span>
<span class="kt">real</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span>           <span class="kd">::</span> <span class="n">values</span><span class="p">(</span><span class="n">iread</span><span class="p">)</span> <span class="c">! real array to be filled with values</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>          <span class="kd">::</span> <span class="n">inums</span>         <span class="c">! number of values successfully read from string</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>  <span class="kd">::</span> <span class="n">delims</span>        <span class="c">! allowed delimiters</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>          <span class="kd">::</span> <span class="n">ierr</span>          <span class="c">! 0 if no error, else column number undecipherable string starts at</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------------</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="mi">256</span><span class="p">)</span>           <span class="kd">::</span> <span class="n">delims_local</span>        <span class="c">! mutable copy of allowed delimiters</span>
<span class="kt">integer</span>                      <span class="kd">::</span> <span class="n">istart</span><span class="p">,</span><span class="n">iend</span><span class="p">,</span><span class="n">lgth</span><span class="p">,</span><span class="n">icol</span>
<span class="kt">integer</span>                      <span class="kd">::</span> <span class="n">i10</span><span class="p">,</span><span class="n">i20</span><span class="p">,</span><span class="n">i40</span>
<span class="kt">real</span>                         <span class="kd">::</span> <span class="n">rval</span>
<span class="kt">integer</span>                      <span class="kd">::</span> <span class="n">ier</span>
<span class="kt">integer</span>                      <span class="kd">::</span> <span class="n">delimiters_length</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------------</span>
      <span class="n">delims_local</span><span class="o">=</span><span class="n">delims</span>                                 <span class="c">! need a mutable copy of the delimiter list</span>
      <span class="k">if</span><span class="p">(</span><span class="n">delims_local</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="s1">&#39;&#39;</span><span class="p">)</span><span class="k">then</span>                          <span class="c">! if delimiter list is null or all spaces make it a space</span>
         <span class="n">delims_local</span><span class="o">=</span><span class="s1">&#39; &#39;</span>                                 <span class="c">! delimiter is a single space</span>
         <span class="n">delimiters_length</span><span class="o">=</span><span class="mi">1</span>                        <span class="c">! length of delimiter list</span>
      <span class="k">else</span>
<span class="k">         </span><span class="n">delimiters_length</span><span class="o">=</span><span class="nb">len_trim</span><span class="p">(</span><span class="n">delims</span><span class="p">)</span>         <span class="c">! length of variable WITH TRAILING WHITESPACE TRIMMED</span>
      <span class="k">endif</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------------</span>
      <span class="n">ierr</span><span class="o">=</span><span class="mi">0</span>                                        <span class="c">! initialize error code returned</span>
      <span class="n">inums</span><span class="o">=</span><span class="mi">0</span>                                       <span class="c">! initialize count of values successfully returned</span>
      <span class="n">istart</span><span class="o">=</span><span class="mi">0</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------------</span>
      <span class="n">lgth</span><span class="o">=</span><span class="mi">0</span>                                        <span class="c">! lgth will be the position of the right-most non-delimiter in the input line</span>
      <span class="k">do </span><span class="n">i20</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">line</span><span class="p">),</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span>                         <span class="c">! loop from end of string to beginning to find right-most non-delimiter</span>
         <span class="k">if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="n">delims_local</span><span class="p">(:</span><span class="n">delimiters_length</span><span class="p">),</span><span class="n">line</span><span class="p">(</span><span class="n">i20</span><span class="p">:</span><span class="n">i20</span><span class="p">)).</span><span class="n">eq</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>   <span class="c">! found a non-delimiter</span>
            <span class="n">lgth</span><span class="o">=</span><span class="n">i20</span>
            <span class="k">exit</span>
<span class="k">         endif</span>
<span class="k">      enddo</span>
<span class="k">      if</span><span class="p">(</span><span class="n">lgth</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>                             <span class="c">! command was totally composed of delimiters</span>
         <span class="k">call </span><span class="n">journal</span><span class="p">(</span><span class="s1">&#39;*string_to_values* blank line passed as a list of numbers&#39;</span><span class="p">)</span>
         <span class="k">return</span>
<span class="k">      endif</span>
<span class="c">!----------------------------------------------------------------------------------------------------------------------------------</span>
<span class="c">!     there is at least one non-delimiter sub-string</span>
<span class="c">!     lgth is the column position of the last non-delimiter character</span>
<span class="c">!     now, starting at beginning of string find next non-delimiter</span>
      <span class="n">icol</span><span class="o">=</span><span class="mi">1</span>                                                     <span class="c">! pointer to beginning of unprocessed part of LINE</span>
      <span class="n">LOOP</span><span class="p">:</span> <span class="k">dO </span><span class="n">i10</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">iread</span><span class="p">,</span><span class="mi">1</span>                                     <span class="c">! each pass should find a value</span>
         <span class="k">if</span><span class="p">(</span><span class="n">icol</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">lgth</span><span class="p">)</span> <span class="k">EXIT </span><span class="n">LOOP</span>                              <span class="c">! everything is done</span>
         <span class="n">INFINITE</span><span class="p">:</span> <span class="k">do</span>
<span class="k">            if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="n">delims_local</span><span class="p">(:</span><span class="n">delimiters_length</span><span class="p">),</span><span class="n">line</span><span class="p">(</span><span class="n">icol</span><span class="p">:</span><span class="n">icol</span><span class="p">)).</span><span class="n">eq</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>           <span class="c">! found non-delimiter</span>
               <span class="n">istart</span><span class="o">=</span><span class="n">icol</span>
               <span class="n">iend</span><span class="o">=</span><span class="mi">0</span>                                            <span class="c">! FIND END OF SUBSTRING</span>
               <span class="k">do </span><span class="n">i40</span><span class="o">=</span><span class="n">istart</span><span class="p">,</span><span class="n">lgth</span>                                <span class="c">! look at each character starting at left</span>
                  <span class="k">if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="n">delims_local</span><span class="p">(:</span><span class="n">delimiters_length</span><span class="p">),</span><span class="n">line</span><span class="p">(</span><span class="n">i40</span><span class="p">:</span><span class="n">i40</span><span class="p">)).</span><span class="n">ne</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>       <span class="c">! determine if character is a delimiter</span>
                     <span class="n">iend</span><span class="o">=</span><span class="n">i40</span>                                    <span class="c">! found a delimiter. record where it was found</span>
                     <span class="k">EXIT</span>                                        <span class="c">! found end of substring so leave loop</span>
                  <span class="k">endif</span>
<span class="k">               enddo</span>
<span class="k">              if</span><span class="p">(</span><span class="n">iend</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="n">iend</span><span class="o">=</span><span class="n">lgth</span><span class="o">+</span><span class="mi">1</span>                           <span class="c">! no delimiters found, so this substring goes to end of line</span>
               <span class="n">iend</span><span class="o">=</span><span class="n">iend</span><span class="o">-</span><span class="mi">1</span>                                       <span class="c">! do not want to pass delimiter to be converted</span>
               <span class="n">rval</span><span class="o">=</span><span class="mf">0.0</span>
               <span class="k">call </span><span class="n">string_to_value</span><span class="p">(</span><span class="n">line</span><span class="p">(</span><span class="n">istart</span><span class="p">:</span><span class="n">iend</span><span class="p">),</span><span class="n">rval</span><span class="p">,</span><span class="n">ier</span><span class="p">)</span>  <span class="c">! call procedure to convert string to a numeric value</span>
               <span class="k">if</span><span class="p">(</span><span class="n">ier</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>                                  <span class="c">! a substring was successfully converted to a numeric value</span>
                  <span class="n">values</span><span class="p">(</span><span class="n">i10</span><span class="p">)</span><span class="o">=</span><span class="n">rval</span>                               <span class="c">! store numeric value in return array</span>
                  <span class="n">inums</span><span class="o">=</span><span class="n">inums</span><span class="o">+</span><span class="mi">1</span>                                  <span class="c">! increment number of values converted to a numeric value</span>
               <span class="k">else</span>                                              <span class="c">! an error occurred converting string to value</span>
                  <span class="n">ierr</span><span class="o">=</span><span class="n">istart</span>                                    <span class="c">! return starting position of substring that could not be converted</span>
                  <span class="k">return</span>
<span class="k">               endif</span>
<span class="k">               </span><span class="n">icol</span><span class="o">=</span><span class="n">iend</span><span class="o">+</span><span class="mi">2</span>                                       <span class="c">! set to next character to look at</span>
               <span class="k">CYCLE </span><span class="n">LOOP</span>                                        <span class="c">! start looking for next value</span>
            <span class="k">else</span>                                                 <span class="c">! this is a delimiter so keep looking for start of next string</span>
               <span class="n">icol</span><span class="o">=</span><span class="n">icol</span><span class="o">+</span><span class="mi">1</span>                                       <span class="c">! increment pointer into LINE</span>
               <span class="k">CYCLE </span><span class="n">INFINITE</span>
            <span class="k">endif</span>
<span class="k">         enddo </span><span class="n">INFINITE</span>
      <span class="k">enddo </span><span class="n">LOOP</span>
<span class="c">!     error &gt;&gt;&gt;&gt;&gt; more than iread numbers were in the line.</span>
<span class="k">end subroutine </span><span class="n">string_to_values</span>
</pre></div>

    </section>
    <br>
    
    
    </div>
  </div>


    <hr>    
    </div> <!-- /container -->
    <footer>
      <div class="container">
      <div class="row">
        <div class="col-xs-6 col-md-4"><p>&copy; 2022 
                                          </p></div>
        <div class="col-xs-6 col-md-4 col-md-push-4">
          <p class="text-right">
            Documentation generated by 
            <a href="https://github.com/cmacmackin/ford">FORD</a>
             on 2022-01-16 22:32  
          </p>
        </div>
        <div class="col-xs-12 col-md-4 col-md-pull-4"><p class="text-center"> M_strings was developed by John S. Urban</p></div>
      </div>
      <br>
      </div> <!-- /container -->    
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<!--
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-->
    <script src="../js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../js/ie10-viewport-bug-workaround.js"></script>

    <!-- MathJax JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
        jax: ['input/TeX','input/MathML','output/HTML-CSS'],
        extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
      });
    </script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    
    <script src="../tipuesearch/tipuesearch_content.js"></script>
    <script src="../tipuesearch/tipuesearch_set.js"></script>
    <script src="../tipuesearch/tipuesearch.js"></script>
    
    
  </body>
</html>